﻿using System;
using System.Collections.Generic;
using System.Configuration;
using chromium.Log;

namespace chromium.Utils
{
    public class Settings
    {
        private static readonly List<string> ip = new List<string>();
        private static readonly List<string> app = new List<string>();
        private static readonly List<string> directHost = new List<string>();
        private static readonly int port;
        private static readonly string mode;
        private static readonly bool https;
        private static readonly bool enableDirectConnect;
        private static readonly bool spdy;
        private static readonly int spdyPort;
        private static readonly LoggingLevel loggingLevel = LoggingLevel.DEBUG;

        static Settings()
        {
            AppSettingsReader reader = new AppSettingsReader();
            ip.AddRange(reader.GetValue("IP", typeof(string)).ToString().Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries));
            app.AddRange(reader.GetValue("App", typeof(string)).ToString().Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries));
            directHost.AddRange(reader.GetValue("DirectConnect", typeof(string)).ToString().Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries));
            port = int.Parse(reader.GetValue("Port", typeof(string)).ToString());
            mode = reader.GetValue("Mode", typeof(string)).ToString();
            https = bool.Parse(reader.GetValue("Https", typeof(string)).ToString());
            enableDirectConnect = bool.Parse(reader.GetValue("EnableDirectConnect", typeof(string)).ToString());
            spdy = bool.Parse(reader.GetValue("SPDY", typeof(string)).ToString());
            spdyPort = int.Parse(reader.GetValue("SPDYPort", typeof(string)).ToString());
            Enum.TryParse(reader.GetValue("LogLevel", typeof(string)).ToString(), true, out loggingLevel);
        }

        public static int Port
        {
            get { return port; }
        }

        public static string Mode
        {
            get { return mode; }
        }

        public static bool Https
        {
            get { return https; }
        }

        public static LoggingLevel LoggingLevel
        {
            get { return loggingLevel; }
        }

        public static bool EnableDirectConnect
        {
            get { return enableDirectConnect; }
        }

        public static bool Spdy
        {
            get { return spdy; }
        }

        public static int SpdyPort
        {
            get { return spdyPort; }
        }

        public static List<string> IP
        {
            get { return ip; }
        }

        public static List<string> App
        {
            get { return app; }
        }

        public static List<string> DirectHost
        {
            get { return directHost; }
        }
    }
}
